from gensim.models import Word2Vec

model = Word2Vec.load("word2vec.model")
# 查找与某个词最相似的词
similar_words = model.wv.most_similar("learning", topn=5)
print("与 'learning' 最相似的词：", similar_words)

# 获取某个词的向量
word_vector = model.wv["natural"]
print("'natural' 的词向量：", word_vector)

# 计算两个词的相似度
similarity = model.wv.similarity("AI", "machine")
print("'AI' 和 'machine' 的相似度：", similarity)

# 找出不匹配的词
odd_one_out = model.wv.doesnt_match(["AI", "machine", "learning", "fascinating"])
print("不匹配的词：", odd_one_out)